;
(function () {

  'use strict';

  angular.module('directives.customActivity')
    .directive('summaryMaxProcessTimeLayout', summaryMaxProcessTimeLayout)
    .directive('summaryMaxProcessTime', summaryMaxProcessTime)
    .directive('summaryAvgProcessTimeLayout', summaryAvgProcessTimeLayout)
    .directive('summaryAvgProcessTime', summaryAvgProcessTime)
    .directive('summaryMinProcessTimeLayout', summaryMinProcessTimeLayout)
    .directive('summaryMinProcessTime', summaryMinProcessTime)
    .directive('summaryMaxThroughput', summaryMaxThroughput)
    .directive('summaryMaxThroughputLayout', summaryMaxThroughputLayout)
    .directive('summaryMaxTps', summaryMaxTps)
    .directive('summaryMaxTpsLayout', summaryMaxTpsLayout)
    .directive('summaryAvgTps', summaryAvgTps)
    .directive('summaryAvgTpsLayout', summaryAvgTpsLayout);

  var temp = '<div class="mypiechart purple" ng-class="class"><div>{{sysPerformance[sys]}}</div><div>{{unit}}</div></div>' +
    '<div>{{sys.toUpperCase() | busLineFilter}}</div>' +
    '<core-loading ng-hide="sysPerformance.loading"></core-loading>';

  function summaryMaxProcessTimeLayout() {

    return {
      restrict: 'E',
      replace: true,
      template: '<div layoutdom="1" draggable="true" class="model" module-name="summary-max-process-time-layout">' +
      '<label class="title title-color2">最大处理耗时</label>' +
      '<div slider slider-include="summary-max-process-time"></div>' +
      '</div>'
    }
  }

  function summaryMaxProcessTime(summaryMaxProcessTimeService) {

    return {
      restrict: 'A',
      template: temp,
      scope: true,
      link: function (scope, element, attrs) {
        scope.sysPerformance = summaryMaxProcessTimeService;
        scope.sys = attrs.summaryMaxProcessTime.toLowerCase();
        scope.unit = '秒';
        scope.class = '';
        summaryMaxProcessTimeService.init();
      }
    }
  }

  summaryMaxProcessTime.$inject = ['summaryMaxProcessTimeService'];

  function summaryAvgProcessTimeLayout() {

    return {
      restrict: 'E',
      replace: true,
      template: '<div layoutdom="1" draggable="true" class="model" module-name="summary-avg-process-time-layout">' +
      '<label class="title title-color2">平均处理耗时</label>' +
      '<div slider slider-include="summary-avg-process-time"></div>' +
      '</div>'
    }
  }

  function summaryAvgProcessTime(summaryAvgProcessTimeService) {

    return {
      restrict: 'A',
      template: temp,
      scope: true,
      link: function (scope, element, attrs) {
        scope.sysPerformance = summaryAvgProcessTimeService;
        scope.sys = attrs.summaryAvgProcessTime.toLowerCase();
        scope.unit = '秒';
        scope.class = '';
        summaryAvgProcessTimeService.init();
      }
    }
  }

  summaryAvgProcessTime.$inject = ['summaryAvgProcessTimeService'];

  function summaryMinProcessTimeLayout() {

    return {
      restrict: 'E',
      replace: true,
      template: '<div layoutdom="1" draggable="true" class="model" module-name="summary-min-process-time-layout">' +
      '<label class="title title-color2">最小处理耗时</label>' +
      '<div slider slider-include="summary-min-process-time"></div>' +
      '</div>'
    }
  }

  function summaryMinProcessTime(summaryMinProcessTimeService) {

    return {
      restrict: 'A',
      template: temp,
      scope: true,
      link: function (scope, element, attrs) {
        scope.sysPerformance = summaryMinProcessTimeService;
        scope.sys = attrs.summaryMinProcessTime.toLowerCase();
        scope.unit = '秒';
        scope.class = '';
        summaryMinProcessTimeService.init();
      }
    }
  }

  summaryMinProcessTime.$inject = ['summaryMinProcessTimeService'];

  function summaryMaxThroughputLayout() {

    return {
      restrict: 'E',
      replace: true,
      template: '<div layoutdom="1" draggable="true" class="model" module-name="summary-max-throughput-layout">' +
      '<label class="title title-color2">最大并发数</label>' +
      '<div slider slider-include="summary-max-throughput"></div>' +
      '</div>'
    }
  }

  function summaryMaxThroughput(summaryMaxThroughputService) {

    return {
      restrict: 'A',
      template: temp,
      scope: true,
      link: function (scope, element, attrs) {
        scope.sysPerformance = summaryMaxThroughputService;
        scope.sys = attrs.summaryMaxThroughput.toLowerCase();
        scope.unit = '个';
        scope.class = 'deepblue';
        summaryMaxThroughputService.init();
      }
    }
  }

  summaryMaxThroughput.$inject = ['summaryMaxThroughputService'];

  function summaryMaxTpsLayout() {

    return {
      restrict: 'E',
      replace: true,
      template: '<div layoutdom="1" draggable="true" class="model" module-name="summary-max-tps-layout">' +
      '<label class="title title-color2">最大吞吐量</label>' +
      '<div slider slider-include="summary-max-tps"></div>' +
      '</div>'
    }
  }

  function summaryMaxTps(summaryMaxTpsService) {

    return {
      restrict: 'A',
      template: temp,
      scope: true,
      link: function (scope, element, attrs) {
        scope.sysPerformance = summaryMaxTpsService;
        scope.sys = attrs.summaryMaxTps.toLowerCase();
        scope.unit = 'tps';
        scope.class = 'blue';
        summaryMaxTpsService.init();
      }
    }
  }

  summaryMaxTps.$inject = ['summaryMaxTpsService'];

  function summaryAvgTpsLayout() {

    return {
      restrict: 'E',
      replace: true,
      template: '<div layoutdom="1" draggable="true" class="model" module-name="summary-avg-tps-layout">' +
      '<label class="title title-color2">平均吞吐量</label>' +
      '<div slider slider-include="summary-avg-tps"></div>' +
      '</div>'
    }
  }

  function summaryAvgTps(summaryAvgTpsService) {

    return {
      restrict: 'A',
      template: temp,
      scope: true,
      link: function (scope, element, attrs) {
        scope.sysPerformance = summaryAvgTpsService;
        scope.sys = attrs.summaryAvgTps.toLowerCase();
        scope.unit = 'tps';
        scope.class = 'blue';
        summaryAvgTpsService.init();
      }
    }
  }

  summaryAvgTps.$inject = ['summaryAvgTpsService'];
})();